package com.briup.recognition.service.impl;

import com.briup.recognition.bean.Interface;
import com.briup.recognition.bean.InterfaceExample;
import com.briup.recognition.dao.InterfaceMapper;
import com.briup.recognition.service.IInterfaceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class InterfaceServiceImpl  implements IInterfaceService{


    @Resource
    private InterfaceMapper interfaceMapper;

    @Override
    public List<Interface> query() {
        InterfaceExample example = new InterfaceExample();
        // 条件

        return interfaceMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(Interface face) {
        if(face.getId() != null){
            interfaceMapper.updateByPrimaryKey(face);
        } else {
            face.setStatus("正常");
            face.setCreatTime(new Date().getTime());
            interfaceMapper.insert(face);
        }
    }

    @Override
    public void deleteById(long id) {
        interfaceMapper.deleteByPrimaryKey(id);
    }
}
